package yagwl.client.model;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

/**
 * Represents the event that is raised when an asynchronous RPI involving data
 * manipulation is completed. Data manipulation includes data fetch from server,
 * delete, update, etc.
 */
public class TreeEvent extends GwtEvent<TreeEvent.TreeEventHandler> {

  public static final Type<TreeEventHandler> TYPE = new Type<TreeEventHandler>();
  private TreeCache treeCache;

  TreeEvent(TreeCache treeCache) {
    super();
    this.treeCache = treeCache;
  }

  /**
   * Gets the cache manager that raised the event
   */
  public TreeCache getTreeCache() {
    return treeCache;
  }

  @Override
  protected void dispatch(TreeEventHandler handler) {
    handler.onTreeEvent(this);
  }

  @Override
  public GwtEvent.Type<TreeEventHandler> getAssociatedType() {
    return TYPE;
  }
  
  public interface TreeEventHandler extends EventHandler {
    public void onTreeEvent(TreeEvent event);
  }

}
